package com.ygh.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ygh.mapper.LeftMenuMapper;
import com.ygh.pojo.LeftMenu;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LeftMenuServiceImpl implements LeftMenuService{
    @Autowired
    private LeftMenuMapper leftMenuMapper;

    @Override
    public List<LeftMenu> getLeftList() {
        QueryWrapper<LeftMenu> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("parent_id", 0);
        List<LeftMenu> onelist = leftMenuMapper.selectList(queryWrapper);
        for(LeftMenu one:onelist){
            QueryWrapper<LeftMenu> queryWrapper1 = new QueryWrapper<>();
            queryWrapper1.eq("parent_id", one.getId());
            List<LeftMenu> twolist = leftMenuMapper.selectList(queryWrapper1);
            one.setChildren(twolist);
        }
        return onelist;
    }
}
